package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.TDicAreaDao;
import com.aaa.ssm.entity.TDicArea;
import com.aaa.ssm.service.TDicAreaService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author
 * @version 1.0.0
 * @ProjectName ssm_elementUI_axios_test_20230323
 * @date 2023/3/31 9:22
 * @description
 */
@Service
public class TDicAreaServiceImpl implements TDicAreaService {
    @Resource
    private TDicAreaDao tDicAreaDao;

    @Override
    public PageInfo queryByParam(Page<TDicArea> page) {
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo((tDicAreaDao.queryByParam(page.getData())));
    }

    @Override
    public TDicArea queryById(Integer code) {
        List<TDicArea> tDicAreasList = tDicAreaDao.queryById(code);
        if (tDicAreasList == null) {
            return null;
        }
        return tDicAreasList.get(0);
    }

    @Override
    public TDicArea queryAll(TDicArea tDicArea) {
        List<TDicArea> tDicAreasList = tDicAreaDao.queryAll();
        if (tDicAreasList == null) {
            return null;
        }
        return tDicAreasList.get(0);
    }

    @Override
    public int add(TDicArea tDicArea) {
        return tDicAreaDao.add(tDicArea);
    }

    @Override
    public int update(TDicArea tDicArea) {
        return tDicAreaDao.update(tDicArea);
    }

    @Override
    public int deleteById(Integer code) {
        return tDicAreaDao.deleteById(code);
    }
}